{extend name="base" /} {block name="css"}
<link rel="stylesheet" href="__ADMIN__/css/form.css"> {/block} {block name="body"}
<div class="admin-main layui-form">
    <div class="layui-field-box">
        <div class="layui-box-searchber" style="overflow: visible">
            <button class="layui-btn layui-btn-danger layui-btn-sm" data-url="{:url('admin/superlinks/alldelete')}" lay-submit lay-filter="alldelete">删除选中</button>
            <a class="layui-btn layui-btn-success layui-btn-sm" href="{:url('admin/superlinks/add')}" lay-submit>添加友链</a>
          
            <form class="layui-form-pane" action="{:url('admin/superlinks/index')}" method="get">

                <div class="layui-form">
                    <div class="layui-inline" style="width:100px">
                        <select name="onwhere" lay-filter="selectonwhere">
                                <option value="">显示位置</option>
                           
                              
                                <option {if condition="$onwhere eq 'default'"}selected="selected"{/if} value="default">BBS</option>
               
                                <option {if condition="$onwhere eq 'cms'"}selected="selected"{/if} value="cms">CMS</option>
              
                              </select>
                    </div>
                    <div class="layui-inline" style="width:100px">
                        <select name="status" lay-filter="selectstatus">
                                <option  value="">状态</option>
                                <option {if condition="$status eq '0'"}selected="selected"{/if} value="0">隐藏</option>
                                <option {if condition="$status eq 1"}selected="selected"{/if} value="1">显示</option>
                              </select>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">名称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="keyword" value="" placeholder="请输入链接名称" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn  layui-btn-sm">搜索</button>
                    </div>
                </div>



            </form>
        </div>
        <hr>
        <table class="layui-table admin-table">
            <thead>
                <tr>
                    <th width="3%" align="center"><input type="checkbox" name="checkAll" lay-filter="checkAll"></th>
                    <th width="10%" align="center">站点名称</th>
                    <th align="center">链接地址</th>
                    <th width="60px" style="text-align:center">类型</th>
                    <th width="60px" style="text-align:center">位置</th>
                    <th width="60px" align="center">显示状态</th>
                    <th width="60px" align="center">联系方式</th>
                    <th width="60px" align="center">创建时间</th>
                    <th width="50px" style="text-align:center">排序</th>
                    <th width="110px" style="text-align:center">操作</th>
                </tr>
            </thead>
            <tbody id="content">
                {volist name="list" id="vo"}
                <tr>
                    <td align="center"><input type="checkbox" name="ids[{$vo.id}]" lay-filter="checkOne" value="{$vo.id}"></td>
                    <td align="center">{$vo.title}</td>
                    <td style="padding-left: 20px;word-break:break-all;word-wrap:break-word">{$vo.link}</td>
                    <td style="padding-left: 20px;">{:$vo['type']=='1'?'图片':'文字'}</td>
                    <td style="padding-left: 20px;">{:$vo['onwhere']=='default'?'BBS':'CMS'}</td>
                    <td align="center">
                        <input type="checkbox" name="show" lay-skin="switch" lay-text="显示|隐藏" lay-filter="switchstatus" value="{$vo['id']}" {php}echo $vo[ 'status']==1 ? 'checked' : '';{/php}>
                    </td>
                    <td style="padding-left: 20px;">{$vo.contacts}</td>
                    <td>{$vo.create_time}</td>
                    <td style="padding-left: 20px;">{$vo.level}</td>
                       <td align="center">
            
                        <a class="layui-btn layui-btn-normal layui-btn-sm" href="{:url('admin/superlinks/edit',array('id'=>$vo['id']))}">修改</a>
                        <a class="elementdel layui-btn layui-btn-danger layui-btn-sm" href="javascript:;" data-id="{$vo.id}" data-url="{:url('admin/superlinks/delete',array('id'=>$vo['id']))}" title="删除">删除</a>
                    </td>
                </tr>
                {/volist}
            </tbody>
        </table>
    </div>


</div>
{/block} {block name="page"}
<div class="btable-paged">
    <div class="layui-main">
        {$list->render()}
    </div>
</div>
{/block} {block name="js"}
<script type="text/javascript" src="__ADMIN__/js/delelement.js"></script>
{/block} {block name="script"}

<script>
    layui.use(['form', 'laydate'], function() {
        var form = layui.form,
            laydate = layui.laydate,
            $form = $('form'),
            jq = layui.jquery;
        form.on('select()', function(data) {
            $form.submit();
        });

        laydate.render({
            elem: '#startdate' //指定元素
                ,
            done: function(value, date) {
                $form.submit();
            }
        });
        laydate.render({
            elem: '#enddate' //指定元素
                ,
            done: function(value, date) {
                $form.submit();
            }
        });
        var status = 0;
        form.on('switch(switchstatus)', function(data) {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            if (data.elem.checked) {
                status = 1;
            } else {
                status = 0;
            }
            var url = "{:url('admin/superlinks/toggle')}?id=" + data.value + '&status=' + status + '&name=status';


            jq.get(url, function(data) {

                if (data.code == 200) {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    });
                } else {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                }
            });
            return false;
        });

        form.on('switch(switchchoice)', function(data) {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            if (data.elem.checked) {
                status = 1;
            } else {
                status = 0;
            }
            var url = "{:url('admin/superlinks/toggle')}?id=" + data.value + '&status=' + status + '&name=choice';


            jq.get(url, function(data) {

                if (data.code == 200) {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    }, function() {
                        //  location.reload();
                    });
                } else {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                }
            });
            return false;
        });
        form.on('switch(switchsettop)', function(data) {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            if (data.elem.checked) {
                status = 1;
            } else {
                status = 0;
            }
            var url = "{:url('admin/superlinks/toggle')}?id=" + data.value + '&status=' + status + '&name=settop';


            jq.get(url, function(data) {

                if (data.code == 200) {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    }, function() {
                        //  location.reload();
                    });
                } else {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                }
            });
            return false;
        });
        form.on('switch(switchmemo)', function(data) {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            if (data.elem.checked) {
                status = 1;
            } else {
                status = 0;
            }
            var url = "{:url('admin/superlinks/toggle')}?id=" + data.value + '&status=' + status + '&name=memo';


            jq.get(url, function(data) {

                if (data.code == 200) {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    }, function() {
                        //  location.reload();
                    });
                } else {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                }
            });
            return false;
        });

    })
</script>
{/block}